import { ReqPage, ResPage } from '@/api/interface'
import { TBY } from '@/api/config/servicePort'
import http from '@/api'

export namespace Person {
  /**查询参数 */
  export interface Query extends ReqPage {
    /**姓名 */
    name?: string
    /**是否审核 */
    isAudit?: string
    /**护林员类型 */
    userType?: string
    /**聘用状态 */
    status?: string
  }

  /**列表内容 */
  export interface Record {
    id: number
    name: string
    phone: string
    isAudit: string
    userType: string
    status: string
    orgName: string
    position: string
  }

  /**详情 */
  export interface Form {
    id: number
    name: string
    photo: string
    orgName: string
    position: string
  }

  export const AuditEnum = [
    { value: '0', label: '否' },
    { value: '1', label: '是' }
  ]

  export const UserTypeEnum = [
    { value: '1', label: '专业护林员' },
    { value: '2', label: '防火护林员' },
    { value: '3', label: '生态护林员' },
    { value: '4', label: '天然林护林员' },
    { value: '5', label: '病虫护林员' }
  ]

  export const StatusEnum = [
    { value: '10', label: '在聘（初聘）' },
    { value: '20', label: '解聘' },
    { value: '30', label: '在聘（续聘）' }
  ]
}

// 分页查询
export const pagePerson = (params: Person.Query) => {
  return http.get<ResPage<Person.Record>>(TBY + `/mountains_person/page`, params)
}

// 详情信息
export const getPersonDetail = (id: number) => {
  return http.get<Partial<Person.Form>>(TBY + `/mountains_person/get`, { id }, { loading: false })
}

// 新增或修改
export const saveOrUpdatePerson = (params: Partial<Person.Form>) => {
  return http.post(TBY + `/mountains_person/save`, params)
}
